﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YasharEl.Infrastructure.ApplicationModel.Bootsrap;
using System.Windows;
using YasharEl.Infrastructure.ObjectFactory;
using YasharEl.Infrastructure.PresentationModel.Prism.Tasks;
using YasharEl.Infrastructure.PresentationModel.Prism.TaskModel;

namespace YasharEl.Infrastructure.ApplicationModel.Prism
{
    public class WpfApplicationBootstrapper : BaseBootstrapper<Application>
    {
        #region Fields

        private PrismApplicationBootstrapper _prismApplicationBootstrapper = new PrismApplicationBootstrapper();

        #endregion

        #region Constructors

        public WpfApplicationBootstrapper()
            :base(true)
        {

        }

        #endregion

        #region BaseBootstrapper<Application> Implementation

        protected override void PrepareApplication()
        {
        }

        protected override void Configure()
        {
        }

        protected override void BuildUp()
        {
            _prismApplicationBootstrapper.Run();
        }

        protected override void PerformPostStartupTask()
        {
            var commandLineArgs = Environment.GetCommandLineArgs();
            var startupTask = DependencyContainer.Resolve<IAppStartupTask, PostAppStartupTask>();
            var startupArgs = DependencyContainer.Resolve<AppStartupTaskArgs>();
            startupArgs.CommandLineArgs = commandLineArgs;
            TaskServiceSingleton.Instance.PerformTask((TaskBase<AppStartupTaskArgs>)startupTask, startupArgs, null);
        }

        #endregion
    }
}
